<!--所有图书-->
<script setup>

import {onMounted, ref} from "vue";
import {get} from "../util/Request.js";
import {Toast} from "tdesign-mobile-vue";
import router from "../router/index.js";

const images=ref([])
onMounted(()=> {
  get("tbBook/find").then(r => {
    if (r.code == 0) {
      images.value = r.data.records
    } else {
      Toast(r.data)
    }
  })
})

const handleClick = () => {
  // localStorage.setItem("id",typeId)
  window.history.back() // 返回上一级页面
};

const jianjie=(r)=>{
  localStorage.setItem("bookName",r)
  router.push("/aiw")
};

</script>

<template>
  <div>
    <t-navbar title="所有图书" :fixed="false" left-arrow @left-click="handleClick" />
  </div>
  <div>
    <div class="image-demo" style="padding: 0 8px;margin-top: 3%;width:95%;height:100%;flex-wrap: wrap;display: flex">
      <div v-for="image in images" @click="jianjie(image.bookName)" style="width: 108px; height: 210px; margin-left: 1.2%;">
        <t-image :src="image.bookImg" class="image-container" style="width: 108px; height: 70%;" />
        <p class="image-demo-tip">{{ image.bookName }}</p>
      </div>
    </div>
  </div>
</template>

<style scoped>

</style>